/* ********************************************************************************************
*  Alvin Baldemeca
*  Tetris Project
*  Course: TCSS 305 , Alan Fowler
*  Term: Spring 2012
*  UNIVERISTY OF WASHINGTON TACOMA
*
*
**********************************************************************************************/

package gui.actions;


import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;


import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Timer;

import view.TetrisGUI;




/**
 * An action that starts a timer.
 * @author Alvin Baldemeca
 * @version 5/25/2012
 */
@SuppressWarnings("serial")
public class StartAction extends AbstractAction
{
    
  /**
   * The timer to start.
   */
  private final Timer my_timer;
  
  /**
   * The GUI to set the environment to its initial state.
   */
  private final TetrisGUI my_gui;
  
  /**
   * Creates a StartAction.
   * @param the_timer the timer to start.
   * @param the_gui The GUI to set the environment to its initial state.
   */
  public StartAction(final Timer the_timer, final TetrisGUI the_gui) 
  {
    super("New Game");
    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_N);
    putValue(Action.SELECTED_KEY, true);
    my_timer = the_timer;
    my_gui = the_gui;
  }

  @Override
  public void actionPerformed(final ActionEvent the_event) 
  {
    my_gui.restGUI();
    my_gui.resetTimer();
    my_timer.start();
  }
    
    
  
  
  
  
  
  
}
